// SPDX-License-Identifier: GPL-2.0-or-later
// Copyright (c) 2023 Yevhen Babiichuk (DustDFG)

#include <DotSort/View/ISFMLTube.hpp>

#include <cstdint>

#include <SFML/Graphics/Texture.hpp>

namespace View
{

ISFMLTube::ISFMLTube(uint8_t size, sf::FloatRect boundsRect)
	: ITube(size)
	, boundsRect(boundsRect)
{}

bool ISFMLTube::contains(sf::Vector2f position)
{
	return this->boundsRect.contains(position);
}

sf::FloatRect ISFMLTube::getSlotRect(uint8_t slotIndex) const
{
	sf::FloatRect rect;

	rect.width = this->boundsRect.width;
	rect.height = (this->boundsRect.height / this->size);

	rect.top = (this->boundsRect.top + this->boundsRect.height) - (rect.height * slotIndex);
	rect.left = this->boundsRect.left;

	return rect;
}

sf::FloatRect ISFMLTube::getOverflowRect() const
{
	sf::FloatRect rect;

	rect.width = this->boundsRect.width;
	rect.height = (this->boundsRect.height / this->size);

	rect.top = this->boundsRect.top - rect.height;
	rect.left = this->boundsRect.left;

	return rect;
}

}
